var _util = require('util/util.js')
var vue = require('./../common/vue')
const { toHandlerKey } = require('vue');
const _market_service = require('service/market-service');

var new_coupon = new vue({
    el: "#new_coupon",
    data: {
        shopnames: ["自律数码店", "自律母婴店"],
        selectshopname: "选择商铺",
        editstock: 0,
        editfullminus: 0,
        editdiscount: 0,
        editavailable: 1,
    },
    methods: {
        addcoupon: function () {
            console.log("开始更新");
            new_coupon.editavailable = new_coupon.editavailable? 1 : 0
            console.log(new_coupon.editavailable)
            console.log(new_coupon.editfullminus)
            console.log(new_coupon.editdiscount)
            console.log(new_coupon.editstock)
            console.log(new_coupon.selectshopname)

            _market_service.addcoupon(
                {   
                    shopname  : new_coupon.selectshopname,
                    fullminus : new_coupon.editfullminus,
                    discount  : new_coupon.editdiscount,
                    stock     : new_coupon.editstock,
                    avalaible : new_coupon.editavailable
                },
                function (res) {
                    alert("保存成功")
                    console.log(res)
                },
                function (err) {
                    alert("保存失败")
                    console.log(err)
                }
            )
        },
    },
    //初始化vue对象，渲染数据
    created: function () {
        获取的购物车商品对象
        _market_service.getallcoupons(coupon_content.pagesize,coupon_content.pageid,
            function (res) {
                coupon_content.coupons = res;
            },
            function (res) {
                console.log("ERROR..*..")
            }
        );
    },

})